const { execSync } = require('child_process');
const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

console.log('请选择一个开发环境:');
console.log('1. dev:h5');
console.log('2. dev:mp-weixin');

rl.question('输入选项编号 (1 或 2): ', (answer) => {
  let command;
  switch (answer) {
    case '1':
      command = 'pnpm dev:h5';
      break;
    case '2':
      command = 'pnpm dev:mp-weixin';
      break;
    default:
      console.log('无效的选项');
      rl.close();
      return;
  }

  try {
    execSync(command, { stdio: 'inherit' });
  } catch (error) {
    console.error(`执行命令 ${command} 时出错:`, error);
  }

  rl.close();
});